package com.blb.day2;

/**
 * 懒汉式单例模式
 */
public class Singleton2 {

    private static Singleton2 instance = null;

    private Singleton2(){
        System.out.println("创建了一个对象");
    }

    public static Singleton2 getInstance(){
        if(instance == null){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            instance = new Singleton2();
        }
        return instance;
    }
}
